﻿<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" autoFlush="true"%>
<%@ taglib uri="/WEB-INF/displaytag.tld" prefix="display"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="/WEB-INF/qautil.tld" prefix="qautil"%>
<logic:present name="pqcat">
<c:url var="backUrl" value="/qcat.mrqa?action=list">
    <c:if test="${not empty pqcat.mrIaskCategory}">
    <c:param name="id" value="${pqcat.mrIaskCategory.id}"/>
    </c:if>
    <c:param name="type" value="${type}"/>
</c:url>
<a href="<c:out value="${backUrl}"/>">返回</a>
    <html:form action="/qcat" method="post" onsubmit="return validate(this)">
    <html:hidden property="parentId"/>
    <html:hidden property="id"/>
    <html:hidden property="action" value="modify"/>
    <html:hidden property="type" value="${type}"/>
<b>分类信息</b>
<table class="its">
    <tbody>
        <tr class="even">
            <td align="right">ID</td>
            <td><bean:write name="pqcat" property="id"/></td>    
        </tr>
        <tr>
            <td align="right">名称</td>
            <td>
                <html:text property="name" name="pqcat"/>
            </td>
        </tr>
        <tr class="even">
            <td align="right">状态</td>
            <td>
                <html:text property="state" name="pqcat"/>(0:正常,1:隐藏)
            </td>
        </tr>
        <tr class="odd">
            <td align="right">优先显示</td>
            <td>
                <html:text property="priority" name="pqcat"/>
            </td>
        </tr>
       <tr class="even">
            <td align="right">分类类型</td>
            <td>
                <html:select property="onlyForAdmin" name="pqcat">
                <html:option value="N">帖子分类</html:option>
                <html:option value="Y">公告分类</html:option>                
                <html:option value="T">调研分类</html:option>
                <html:option value="I">内部分类</html:option>
                </html:select>
            </td>
        </tr>
    <tr class="even">
        <td></td>
        <td>
            <p>(公告分类下存放公告信息,调研分类下存放调研信息,调研分类和公告分类目前只支持一级;<br>
            内部分类用于内部交流使用，仅供高级用户和管理员，普通用户无法看到这三个特殊分类;<br>
            如果帖子分类被隐藏，请同时也将此分类设置为内部分类，以保证帖子列表和搜索的正确性;<br>
            招聘或培训分类都是普通帖子分类.
            )</p>
        </td>        
    </tr>
        <tr>
            <td align="right">广告(招聘或培训)</td>
            <td>
                <html:checkbox property="isAds" name="pqcat"/>“名企招聘”下子分类如EDS，先设置为“帖子分类”再选择此选项<br>
                <html:checkbox property="isTraining" name="pqcat"/>是否是培训.原则上招聘和培训属性是互相排斥的.
            </td>
        </tr>
        <tr class="even">
            <td align="right">广告分类联系人电子邮件</td>
            <td>
                <html:text property="adCategoryContactMail" size="90" name="pqcat"/>
            </td>
        </tr>
        <tr class="even">
            <td></td>
            <td>
                此电子邮件用于
                <br>1.接收上传的简历;(如果分类下有招聘帖子，则此项必须填写。如果子分类被设置成招聘分类，父分类也强制设置为招聘分类)
                <br>2.发送培训报名信息.
                <br>3.发送活动报名信息.
                <br>多个电子邮件用,隔开.
            </td>
        </tr>
        <tr>
            <td align="right">是否锁帖</td>
            <td>
                <html:checkbox property="isLock" name="pqcat"/>锁帖<br>
            </td>
        </tr>
        <tr class="even">
            <td colspan="2" align="center" style="text-align:center">
                <html:submit value="修改"/>&nbsp;&nbsp;&nbsp;&nbsp;
                <c:if test="${pqcat.onlyForAdmin == 'N' or pqcat.onlyForAdmin == 'I'}">
                    <input type="button" name="addBtn" value="增加子分类" onclick="addCat(this.form)"/>&nbsp;&nbsp;&nbsp;&nbsp;
                </c:if>
                <bean:size id="catssize" name="qcats"/>
                <logic:lessThan value="1" name="catssize">
                    <input type="button" value="删除" onclick="delCat(this.form)"/>
                </logic:lessThan>
            </td>
        </tr>
    </tbody>
</table>
    </html:form>
<br>    
</logic:present>
<table align="center" width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td>   
            <span class="title1">帖子子分类</span>
        </td>
        <td align="right">总数:<b><c:out value="${cresultSize}"/></b>&nbsp;&nbsp;</td>
    </tr>
</table>    
<display:table name="qcats" class="its" id="qcat1">
    <display:column property="id" title="ID" />
    <display:column property="name" title="名称" />
    <display:column property="state" title="状态" />
    <display:column property="level" title="层级" />
    <display:column property="priority" title="优先显示" />
    <display:column property="onlyForAdmin" title="分类类型" />
    <display:column title="广告属性">
        <c:if test="${qcat1.isAds}">广告分类</c:if>
        <c:if test="${qcat1.isTraining}">培训分类</c:if>
    </display:column>
    <display:column title="操作">
    	<c:url var="modifyUrl" value="/qcat.mrqa?action=list">
    		<c:param name="action" value="list"/>
    		<c:param name="id" value="${qcat1.id}"/>
    		<c:param name="type" value="${type}"/>
    	</c:url>
    	<a href="<c:out value="${modifyUrl}"/>">修改</a> 
    </display:column>
</display:table>
<logic:notPresent name="pqcat">
    <div align="right">
    <input type="button" name="migrBtn" value="转移帖子" onclick="migrateQuestions(this)"/>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="button" name="addBtn" value="增加一级分类" onclick="addCat(this)"/>
    </div>
</logic:notPresent>
<script type="text/javascript">
    var contextPath = "<%=request.getContextPath()%>";
    function validate(pForm)
    {
        if(pForm.name.value == "")
        {
            alert("[名称]必须输入");pForm.name.focus();
        }
        return true;
    }
    function migrateQuestions(pButton)
    {
        var url = contextPath+"/qm.mrqa?action=premigr&type=<c:out value="${type}"/>";
        document.location.href = url;
    }        
    function addCat(pButton)
    {
        var url = contextPath+"/qcat.mrqa?action=preadd&parentId=<c:out value="${pqcat.id}"/>&type=<c:out value="${type}"/>";
        document.location.href = url;
    }        
    function delCat(pForm)
    {
        var url = contextPath+"/qcat.mrqa?action=predelete&id=<c:out value="${pqcat.id}"/>&type=<c:out value="${type}"/>";
        document.location.href = url;
    }
</script>
<c:if test="${param.id != null}">
<br><span class="title1">帖子</span>
<display:table name="questions" class="mars" id="question" cellpadding="1" cellspacing="1">
    <display:column title="标题">
        <html:link page="/question.mrqa?action=view" paramId="id" paramName="question" paramProperty="id">
            <bean:write name="question" property="title"/>
        </html:link>
        <c:if test="${question.isPoll == '1'}">
                （投票项）
        </c:if>
    </display:column>
    <display:column title="访问" style="text-align:right;">
        <c:out value="${question.viewCount}"/>
    </display:column>
    <display:column title="回复" style="text-align:right;">
        <c:out value="${fn:length(question.mrIaskAnswers)}"/>
    </display:column>
    <display:column property="postDate" title="日期" format="{0,date,yyyy-MM-dd hh:mm}"/>
    <display:column title="作者">
        <c:set var="user_id" value="${question.mrIaskUser.id}"/>
        <html:link page="/user.mrqa?action=viewuserbyother" styleId="author" paramId="id" paramName="user_id">
            <c:out value="${question.mrIaskUser.loginName}"/>
        </html:link>                
    </display:column>
    <display:column title="操作">
        <logic:equal value="0" property="state" name="question">
            <html:link page="/question.mrqa?action=close&from=admin" paramId="id" paramName="question" paramProperty="id">
                隐藏
            </html:link>
        </logic:equal>
        <logic:equal value="4" property="state" name="question">
            <html:link page="/question.mrqa?action=reopen&from=admin" paramId="id" paramName="question" paramProperty="id">
                重开
            </html:link>
        </logic:equal>
        <logic:equal value="1" property="state" name="question">
                <html:link page="/question.mrqa?action=close&from=admin" paramId="id" paramName="question" paramProperty="id">
                    关闭
                </html:link>
        </logic:equal>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <html:link page="/question.mrqa?action=delete&from=admin" paramId="id" paramName="question" paramProperty="id">
                删除
            </html:link>
    </display:column>
</display:table>
</c:if>
<qautil:page action="/qcat.mrqa"/>